/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.workforce.common.tags;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;

/**
 *
 * @author neo
 */
public class InitParameterTag extends TagSupport {
    private String name;
    private String init = "";

    @Override
    public int doStartTag() throws JspException {
        String pname = pageContext.getRequest().getParameter(name);
        pname = (pname == null) ? init : pname;
        pageContext.setAttribute(name, pname, PageContext.PAGE_SCOPE);
        return super.doStartTag();
    }

    @Override
    public int doEndTag() throws JspException {
        return super.doEndTag();
    }

    public void setInit(String init) {
        this.init = init;
    }

    public void setName(String name) {
        this.name = name;
    }



}
